package com.zzt.zt_autocompletetextview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import java.util.regex.Pattern

class MainActivity : AppCompatActivity() {

    var rv_list: RecyclerView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
    }

    private fun initView() {
        rv_list = findViewById(R.id.rv_list)

        var listData: MutableList<String> = mutableListOf();
        listData.add("1")
        listData.add("22")
        listData.add("333")
        listData.add("4444")
        listData.add("55555")
        listData.add("666666")
        listData.add("7777777")
        listData.add("88888888")
        listData.add("999999999")
        listData.add("0000000000")

        var mAdapter = MyRecycleAdapter(listData)

        rv_list?.layoutManager = LinearLayoutManager(this@MainActivity)
        rv_list?.adapter = mAdapter


        var content =
            "operationID[1664522104277], clientMsgID[23b391e56953a08a0d9be1c68df637ac], info[==> open_im_sdk/internal/interaction.(*Ws).SendReqWaitResp()@118: SendReqWaitResp failed: send failed]"
        getClientMsgId(content)

    }


    fun getClientMsgId(content: String) {
        val regex = "clientMsgID\\[+.*\\],"
        val msgPattern = Pattern.compile(regex)
        val matcher = msgPattern.matcher(content)
        while (matcher.find()) {
            val msgId = content.substring(matcher.start() + 1, matcher.end()-2)
            Log.d("TAG", "我这个匹配的字符：$msgId")
        }
    }


}